package cs294s.liveradar.service;

import java.text.SimpleDateFormat;
import java.util.Date;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class Util {
	public static String timeFormat(Date d) {
		SimpleDateFormat formatter
        = new SimpleDateFormat ("EEEE MMM d, yyyy 'at' h:mm a");
		return formatter.format(d);
	}

	public static boolean isNetworkAvailable(Context c) {
		   ConnectivityManager connectivity = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE);
		   if (connectivity == null) {
		     return false;
		   } else {
		      NetworkInfo[] info = connectivity.getAllNetworkInfo();
		      if (info != null) {
		         for (int i = 0; i < info.length; i++) {
		            if (info[i].getState() == NetworkInfo.State.CONNECTED) {
		               return true;
		            }
		         }
		      }
		   }
		   return false;
	}



}
